// @ts-nocheck
import {Plugin, TransformResult} from 'vite';
import * as path from "path";

const fileType = ['.sass', '.scss', '.less', '.css']

export default function vitePluginVueDeep(): Plugin {
  return {
    enforce: 'pre',
    name: "vite:vite-plugin-vue-deep",
    transform(code: string, id: string): Promise<TransformResult> | TransformResult {
      if (fileType.includes(path.extname(id))) {
        if (code.includes('/deep/')) {
          code = code.replace(/\/deep\//g, '::v-deep')
        }
      }
      return {
        code,
        map: null
      };
    }

  }
}
